﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASBCC.Business;
using ASBCC.Business.CIS;

namespace BEGDC.CC.Web.CIS2.Domestic
{
    public partial class CustomerOC : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var companyID = Request.QueryString["CompanyID"];
                if (!String.IsNullOrEmpty(companyID))
                {
                    ocShow = CustomerOCHelper.GetOCString(int.Parse(companyID));
                }
                selectCompany.DataBind();
                selectCompany.SelectedValue = companyID;
            }
            var roles = (this.User as CSPrincipal).Role2s;
            string allrole = "";
            if (roles != null && roles.Count() != 0)
            {
                foreach (var role in roles)
                {
                    allrole += role;
                    allrole += ",";
                }
                allrole = allrole.Substring(0, allrole.Length - 2);
            }
            this.edsCompany.Where += (" and it.CompanyID in {" + CustomerManageHelper.GetCompanyByRoleID(allrole) + "}");
        }


        protected string ocShow = "[]";

        protected void btnOK_Click(object sender, EventArgs e)
        {
            int companyID = int.Parse(this.selectCompany.SelectedValue);
            ocShow = CustomerOCHelper.GetOCString(companyID);
        }

        

    }
}
